package com.egame.manage.biz.server.gc;

import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import cn.egame.common.exception.ExceptionCommonBase;
import cn.egame.common.util.Utils;
import cn.egame.interfaces.EnumType.GameStatus;
import cn.egame.interfaces.gc.GameInfo;
import cn.egame.interfaces.gc.GameTagInfo;
import com.egame.manage.biz.server.ManageClient;

public class GameTagServiceImpl {
	
	private static GameTagServiceImpl instance = null;
	private static byte[] SyncRoot = new byte[1];
	private GameTagServiceDao dao = null;
	
	public static GameTagServiceImpl getInstance() throws ExceptionCommonBase {
		if (instance == null) {
			synchronized (SyncRoot) {
				if (instance == null) {
					instance = new GameTagServiceImpl();
				}
			}
		}
		return instance;
	}
	
	public GameTagServiceImpl() throws ExceptionCommonBase{
		super();
		dao = new GameTagServiceDao();
	}
	
	public List<GameInfo> listGameInfoByTagId(int appId,long loginUserId,int tagId,String name) throws RemoteException{
		List<Integer> ids = dao.listGameIdByGameTagId(tagId,name);
		List<GameInfo> list = new ArrayList<GameInfo>();
		GameInfo bean = null;
		for(Integer id:ids){
			bean = GameServiceImpl.getInstance().getGameInfoById(appId, loginUserId, id);
			list.add(bean);
		}
		
		return list;
	}
	
	public int upper(int appId, long loginUserId, int gId, int tagId) throws RemoteException {
		return dao.upper(appId ,loginUserId,gId, tagId);
	}

	public int lower(int appId, long loginUserId, int gId, int tagId) throws RemoteException {
		return dao.lower(appId ,loginUserId,gId, tagId);
	}
	
	public List<Integer> listGidByNotTagId(int gameTagId,int gId,String name) throws ExceptionCommonBase{
		return dao.listGidByNotTagId(gameTagId,gId,name);
	}

	public int top(int appId, long loginUserId, int gId, int tagId) throws RemoteException {
		return dao.top(appId ,loginUserId,gId, tagId);
	}

	public int down(int appId, long loginUserId, int gId, int tagId) throws RemoteException {
		return dao.down(appId ,loginUserId,gId, tagId);
	}

	public int addTagLink(int appId, long loginUserId, int gId, int tagId, int tagSortNo, int gameSortNo)  throws RemoteException{
		return dao.addTagLink(appId ,loginUserId,gId, tagId, tagSortNo, gameSortNo);
	}
	
	public int deleteTagLink(int appId, long loginUserId,int gId,int tagId)throws ExceptionCommonBase {
		return dao.deleteTagLink(gId, tagId);
	}

	public int deleteTag(int appId, long loginUserId, int tagId) throws ExceptionCommonBase {
		return dao.deleteTag(tagId);
	}

	public int addTag(int appId, long loginUserId, GameTagInfo bean) throws ExceptionCommonBase {
		return dao.addTag(bean);
	}
	
	public int disableTagLinkByGid(int gId)throws ExceptionCommonBase {
		return dao.disableTagLinkByGid(gId);
	}
	
	public int enableTagLinkByGid(int gId)throws ExceptionCommonBase {
		return dao.enableTagLinkByGid(gId);
	}
	
	public List<String> getNameList() throws ExceptionCommonBase {
		return dao.getNameList();
	}
	
	public int setGameTagInfo(GameTagInfo bean) throws ExceptionCommonBase {
		return dao.setGameTagInfo(bean);
	}
}
